﻿//using System;
//using System.Collections.Generic;
//using System.Text;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Threading;
using System.IO;
using System.IO.Ports;
using Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;

namespace WarehouseManager
{
    public partial class SQL_APPL
    {
        public partial class Converter
        {
            private static char[] tcvnchars = {
                        'µ', '¸', '¶', '·', '¹', 
                        '¨', '»', '¾', '¼', '½', 'Æ', 
                        '©', 'Ç', 'Ê', 'È', 'É', 'Ë', 
                        '®', 'Ì', 'Ð', 'Î', 'Ï', 'Ñ', 
                        'ª', 'Ò', 'Õ', 'Ó', 'Ô', 'Ö', 
                        '×', 'Ý', 'Ø', 'Ü', 'Þ', 
                        'ß', 'ã', 'á', 'â', 'ä', 
                        '«', 'å', 'è', 'æ', 'ç', 'é', 
                        '¬', 'ê', 'í', 'ë', 'ì', 'î', 
                        'ï', 'ó', 'ñ', 'ò', 'ô', 
                        '­', 'õ', 'ø', 'ö', '÷', 'ù', 
                        'ú', 'ý', 'û', 'ü', 'þ', 
                        '¡', '¢', '§', '£', '¤', '¥', '¦'
            };

            private static char[] unichars = {
                        'à', 'á', 'ả', 'ã', 'ạ', 
                        'ă', 'ằ', 'ắ', 'ẳ', 'ẵ', 'ặ', 
                        'â', 'ầ', 'ấ', 'ẩ', 'ẫ', 'ậ', 
                        'đ', 'è', 'é', 'ẻ', 'ẽ', 'ẹ', 
                        'ê', 'ề', 'ế', 'ể', 'ễ', 'ệ', 
                        'ì', 'í', 'ỉ', 'ĩ', 'ị', 
                        'ò', 'ó', 'ỏ', 'õ', 'ọ', 
                        'ô', 'ồ', 'ố', 'ổ', 'ỗ', 'ộ', 
                        'ơ', 'ờ', 'ớ', 'ở', 'ỡ', 'ợ', 
                        'ù', 'ú', 'ủ', 'ũ', 'ụ', 
                        'ư', 'ừ', 'ứ', 'ử', 'ữ', 'ự', 
                        'ỳ', 'ý', 'ỷ', 'ỹ', 'ỵ', 
                        'Ă', 'Â', 'Đ', 'Ê', 'Ô', 'Ơ', 'Ư'
            };

            private static char[] convertTable;

            static Converter()
            {
                convertTable = new char[256];
                for (int i = 0; i < 256; i++)
                    convertTable[i] = (char)i;
                for (int i = 0; i < tcvnchars.Length; i++)
                    convertTable[tcvnchars[i]] = unichars[i];
            }

            public string TCVN3ToUnicode(string value)
            {
                char[] chars = value.ToCharArray();
                for (int i = 0; i < chars.Length; i++)
                    if (chars[i] < (char)256)
                        chars[i] = convertTable[chars[i]];
                return new string(chars);
            }
        }

        public bool isNumeric(string val, System.Globalization.NumberStyles NumberStyle)
        {
            Double result;
            return Double.TryParse(val, NumberStyle,
                System.Globalization.CultureInfo.CurrentCulture, out result);
        }
    }
}